1

In the addon of the session, we calculated the distances to the closest hospitals located within North-Rhine Westphalia (NRW) and Baden Wurttemberg (BW). Still, we did not show how to subset the original file, which contains all hospitals in Germany.

Subset the data file yourself by relying on the spatial information of the file hospital_points.csv and a polygon of NRW only. How many hospitals are located within the borders of NRW?
You need two datasets for that: the point layer hospital_points.csv in the ./data folder and polygons of NRW. For the latter, you can again use the osmdata syntax.

The default of sf::st_join() will leave you with a ‘left-join’ and returns a data object with all hospitals and matching district information for those which are located within NRW. You can reset the option to perform an ‘inner-join’ and keep only the observation which lay within the predefined area (sf::st_join(x , y, join = "", left = FALSE)).

2

Did the operationalization of health care provision convince you? Don’t you think it might be more important how many hospitals are close to survey respondents? To test this, we want to calculate the number of hospitals per district in North-Rhine Westphalia. Use the syntax below to prep the hospital data.

Earn extra points by counting not only the number of hospitals but also the sum of hospital beds within a district.
You need a dplyr::as_tibble() data frame to use the functions dplyr::group_by() and dplyr::summarise().
The function dplyr::n() allows summarizing the total count of hospitals. sum(beds) for summarizing the bed total per district.